package view.render.monster
{
	
	import enums.ColorLib;
	import enums.main.UISize;
	
	import model.vo.monster.LMonsterSizeVo;
	
	import starling.text.TextField;
	import starling.utils.Color;
	
	import view.render.BaseItem;
	
	
	/**
	 * 大型怪物-体型列表item
	 * @author £iang
	 * 
	 */	
	public class LMonsterSizeListItem extends BaseItem
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** 体型范围 */
		public var rangeLabel:TextField;
		/** 出现任务 */
		public var appearLabel:TextField;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 初始化函数 
		 * 
		 */		
		override protected function initializeOther():void
		{
			rangeLabel = new TextField(
				UISize.MAIN_W * 0.35, 
				_itemH * UISize.DPI_SCALE,
				"", "微软雅黑,宋体", 24 * UISize.DPI_SCALE, Color.WHITE
			);
			rangeLabel.vAlign = "center";
			rangeLabel.hAlign = "left";
			this.addChild( rangeLabel );
			
			appearLabel = new TextField(
				UISize.MAIN_W * 0.5, 
				_itemH * UISize.DPI_SCALE,
				"", "微软雅黑,宋体", 24 * UISize.DPI_SCALE, Color.WHITE
			);
			appearLabel.vAlign = "center";
			appearLabel.hAlign = "left";
			this.addChild( appearLabel );
		}
		
		/**
		 * 调整组件 
		 * 
		 */		
		override protected function draw():void
		{
			var padding:Number = UISize.TITLE_PADDING_LEFT * UISize.DPI_SCALE;
			var firstLabelFullW:Number;
			
			firstLabel.x = padding;
			firstLabelFullW = UISize.MAIN_W * _firstPercent;
			
			rangeLabel.x = UISize.MAIN_W * 0.15;
			rangeLabel.width =  UISize.MAIN_W * 0.35;
			
			appearLabel.x = UISize.MAIN_W * 0.5;
			appearLabel.width = UISize.MAIN_W * 0.5;
			
			this.width = UISize.MAIN_W;
			this.height = _itemH * UISize.DPI_SCALE;
		}
		
		/**
		 * 设置item数据 
		 * @param data 数据
		 * 
		 */		
		public function setData( data:LMonsterSizeVo ):void
		{
			firstLabel.text = data.distinction;
			rangeLabel.text = data.range;
			appearLabel.text = data.appear;
			
			if ( data.distinction.charAt( 0 ) == "基" )
			{
				firstLabel.color = ColorLib.IMPORTANT;
				rangeLabel.color = ColorLib.IMPORTANT;
			}
		}
		//-----------------------------
		// events
		//-----------------------------
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 析构函数
		 * 
		 */		
		protected override function disposeOther():void
		{
			disposeLabels( [
				"range", "appear"
			] );
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function LMonsterSizeListItem()
		{
			super();
			_itemH = UISize.LMONSTER_SIZE_ITEM_H;
			_firstPercent = 0.15;
			initialize();
		}
	}
}